import random

from src.main.utils import Log_ou


class Data_source:

    def get_faker_number(self):
        import faker
        Log_ou.info('生成模拟数据：手机号')

        fake = faker.Faker(locale='zh_CN')  # 初始化，指定生成中文格式数据
        phone = fake.phone_number()  # 生成一条电话号码
        return phone

    def generate_random_chinese(self,num=10):
        Log_ou.info('生成模拟数据：名称')
        chinese_chars = [chr(random.randint(0x4e00, 0x9fff)) for _ in range(num)]
        print(f'xxx{chinese_chars}')
        return ''.join(chinese_chars)

    import random

    def GBK2312(self,num=3):

        list_data = []
        Log_ou.info('生成模拟数据：名称')
        for _ in  range(num):
            head = random.randint(0xb0, 0xf7)
            body = random.randint(0xa1, 0xfe)
            val = f'{head:x}{body:x}'
            str = bytes.fromhex(val).decode('gb2312')
            list_data.append(str)

        str = ''.join(list_data)
        # print(str)

        return str

    def get_faker_account(self):
        import faker
        Log_ou.info('生成模拟数据:随机数')

        fake = faker.Faker(locale='zh_CN')  # 初始化，指定生成中文格式数据
        name = fake.random_number(10) # 生成一条电话号码
        return name

    def get_data_of_name(self):
        list_data = []
        list_data.append(' ')
        list_data.append('')
        list_data.append(self.GBK2312(100))
        list_data.append(self.GBK2312(3))

        # print(list_data)
        return list_data



if __name__ == '__main__':
    # Data_source().get_data_of_name()
    # Data_source().GBK2312()
    demo()

